package com.ringtheweb.persistence.dao.jpa;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ringtheweb.model.UserStatusType;
import com.ringtheweb.model.notification.Notification;
import com.ringtheweb.model.notification.RegistrationQueryNotification;
import com.ringtheweb.persistence.dao.INotificationDAO;

@Repository("notificationDAO")
public class NotificationDAO extends GenericJPADAO<Notification,Long> implements INotificationDAO{

	@Override
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@SuppressWarnings("unchecked")
	public List<RegistrationQueryNotification> findRegistrationQueriesWithMaxCount(
			final int maxcount) {
		return getEntityManager().createNamedQuery("findFailedWithMaxCountsForUser")
				.setParameter("maxCount", maxcount)
				.setParameter("type", UserStatusType.TO_BE_APPROVED)
				.getResultList();
	}

	

}
